<template>
	<view>
		<view class="container" @click="selGG($event)">
			<view class="specification">
				<view class="title">颜色</view>
				<view class="item">
					<text :class="currentData.spec=='颜色:黑色'?'spec active':'spec'" data-spec="颜色:黑色">黑色</text>
					<text :class="currentData.spec=='颜色:白色'?'spec active':'spec'" data-spec="颜色:白色">白色</text>
				</view>
			</view>
			<view class="specification">
				<view class="title">尺码</view>
				<view class="item">
					<text data-spec2="尺码：42" :class="currentData.spec2=='尺码：42'?'spec active':'spec'">42</text>
					<text data-spec2="尺码：41" :class="currentData.spec2=='尺码：41'?'spec active':'spec'">41</text>
					<text data-spec2="尺码：44" :class="currentData.spec2=='尺码：44'?'spec active':'spec'">44</text>
					<text data-spec2="尺码：43" :class="currentData.spec2=='尺码：43'?'spec active':'spec'">43</text>
					<text data-spec2="尺码：39" :class="currentData.spec2=='尺码：39'?'spec active':'spec'">39</text>
					<text data-spec2="尺码：38" :class="currentData.spec2=='尺码：38'?'spec active':'spec'">38</text>
				</view>
			</view>
		</view>
		<view class="number-select" @click="numEvent">
			<view class="left">
				数量
			</view>
			<uni-number-box v-model="num" :min="1" :max="1"/>
		</view>
	</view>
	
</template>

<script>
	export default {
		name:"product-sku",
		props:{
			currentData:{
				type:Object,
				default:()=>{
					return {}
				}
			}
		},
		data() {
			return {
				num:1
			};
		},
		methods:{
			numEvent(){
				uni.showToast({
					icon:"none",
					title:"该商品限购一件"
				})
			},
			selGG(e){
				let {dataset} = e.target;
				this.$emit('change',dataset)
				// this.specObj = Object.assign({},this.specObj,dataset)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		display: flex;
		flex-direction: column;
		.specification{
			margin-top: 30rpx;
			display: flex;
			flex-direction: column;
			.title{
				margin-bottom: 20rpx;
				font-weight: 600;
			}
			.item{
				.spec{
					min-width: 120rpx;
					height: 80rpx;
					margin-right: 20rpx;
					margin-top: 10rpx;
					border-radius: 10rpx;
					border: 2px solid #f5f5f5;
					align-items: center;
					justify-content: center;
					text-align: center;
					display: inline-flex;
					background: #f5f5f5;
					padding: 16rpx;
				}
				.active{
					background: #fff;
					color: $theme-color;
					border: 2px solid $theme-color;
					position: relative;
					border-radius: 10rpx;
					&:before{
						content: "";
						width: 30rpx;
						height: 30rpx;
						position: absolute;
						top: 0;
						right: 0;
						background-image: url();
						background-repeat: no-repeat;
						background-size: 100%;
					}
				}
			}
		}
	}
	.number-select{
		width: 100%;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 30rpx auto;
	}
</style>